package edu.sctu.practice.class02.hujie.cgs.assign03.One;
//测试类
/**
 * Created by hj on 2015/11/2.
 */
public class TestPolymorphism {
    public static void main(String[] args) {
        GeometricObject geoObject1 = new Circle(5);
        GeometricObject geoObject2 = new Rectangle(5,3);

        System.out.println("The three objects have the same area?" +
                equalsArea(geoObject1, geoObject2));

        displayGeometricObject(geoObject1);
        displayGeometricObject(geoObject2);

    }

    // A method for comparing the areas of three geometric objects
    //一种比较几何对象区域的方法
    static boolean equalsArea(GeometricObject object1, GeometricObject object2) {
        return object1.findArea() == object2.findArea();
    }

    // A method for displaying a geometric object
    //一种展示几何对象区域的方法
    static void displayGeometricObject(GeometricObject object) {
        System.out.println();
        System.out.println(object.toString());
        System.out.println("The area is：" + object.findArea());
        System.out.println("The perimeter is：" + object.findPerimeter());
    }
}
